﻿<view:ViewPageBase x:Class="ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Views.Home"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                   xmlns:view="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Views"
                   xmlns:viewmodel="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.ViewModels"
                   xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
                   xmlns:Behaviors="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Behaviors"
                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                   xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                   xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
                   xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
                   xmlns:Command="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Command"
                   mc:Ignorable="d"
                   xmlns:web="clr-namespace:ASPItalia.ModelVirtualCasting.Web.RiaServices"
                   xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                   xmlns:ext="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.MarkupExtensions"
                   xmlns:nav="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.BackOffice.Navigation"
                   nav:Navigator.Source="{Binding}"
                   d:DesignWidth="640"
                   d:DesignHeight="480"
                   Title="Home Page">
    <view:ViewPageBase.ViewModel>
        <viewmodel:HomeViewModel />
    </view:ViewPageBase.ViewModel>
    <view:ViewPageBase.Resources>
        <DataTemplate DataType="web:CandidateType">
            <StackPanel Orientation="Horizontal"
                        d:DesignWidth="111"
                        d:DesignHeight="71">
                <Ellipse Fill="#FFF4F4F5"
                         Height="12"
                         Stroke="Black"
                         Width="12"
                         HorizontalAlignment="Left" />
                <TextBlock Foreground="Red"
                           Text="{Binding Name}"
                           Margin="10,0,0,0" />
            </StackPanel>
        </DataTemplate>
        <DataTemplate DataType="web:ModelType">
            <StackPanel Orientation="Horizontal"
                        d:DesignWidth="191"
                        d:DesignHeight="146">
                <Path Data="M0.5,0.5 C3.9407659,4.3967872 7.6141758,4.2804651 11.5,0.5 C8.9742937,4.1666665 8.9096975,7.8333335 11.5,11.5 C8.0544672,8.6805449 4.3900456,8.6519213 0.5,11.5 C4.1328154,7.8333335 3.8337457,4.1666665 0.5,0.5 z"
                      Fill="#FF39FF00"
                      Stretch="Fill"
                      Stroke="Black"
                      Width="12"
                      UseLayoutRounding="False"
                      StrokeLineJoin="Bevel"
                      Height="12" />
                <TextBlock Foreground="Blue"
                           Text="{Binding Name}"
                           FontStyle="Italic"
                           Margin="10,0,0,0" />
            </StackPanel>
        </DataTemplate>
        <Storyboard x:Name="Storyboard1"
                    AutoReverse="True"
                    RepeatBehavior="Forever">
            <DoubleAnimation Duration="0:0:1"
                             To="300"
                             From="40"
                             Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)"
                             Storyboard.TargetName="rectangle"
                             d:IsOptimized="True" />
        </Storyboard>
    </view:ViewPageBase.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Border VerticalAlignment="Center"
                Background="#FF72B2E4"
                CornerRadius="0">
            <StackPanel Orientation="Horizontal">
                <StackPanel VerticalAlignment="Center"
                            Margin="10"
                            Orientation="Horizontal">
                    <TextBlock TextWrapping="Wrap"
                               Text="{ext:Localization Key=Filter_By_Type}"
                               VerticalAlignment="Center" />
                    <ComboBox ItemsSource="{Binding PeopleTypesView}"
                              TextSearch.TextPath="Name"
                              MinWidth="130"
                              VerticalAlignment="Center">
                        <!--<ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>-->
                    </ComboBox>
                </StackPanel>
                <StackPanel  Margin="10"
                             VerticalAlignment="Center"
                             Orientation="Horizontal">
                    <TextBlock TextWrapping="Wrap"
                               Text="{ext:Localization Key=Filter_By_Surname}"
                               VerticalAlignment="Center" />
                    <TextBox TextWrapping="Wrap"
                             Style="{StaticResource textBoxBaseStyle}"
                             Text="{Binding StringSearch, Mode=TwoWay}"
                             VerticalAlignment="Center"
                             MinWidth="224" />
                </StackPanel>
                <Button Content="Filtra"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Margin="5,0,0,0"
                        Command="{Binding FilterCommand}"
                        MinWidth="45">
                    <!--<i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard1}"
                                                        ControlStoryboardOption="Play" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>-->
                </Button>
            </StackPanel>
        </Border>
        <data:DataGrid x:Name="dg1"
                       AutoGenerateColumns="False"
                       ItemsSource="{Binding People}"
                       Command:DoubleClick.Command="{Binding ViewDetailsCommand, Mode=OneWay}"
                       Command:DoubleClick.CommandParameter="{Binding SelectedItem, ElementName=dg1, Mode=OneWay}"
                       IsReadOnly="False"
                       RowStyle="{StaticResource DataGridRowStyle}"
                       Grid.Row="1"
                       Margin="0,5">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <cmd:EventToCommand Command="{Binding SelectionChangedCommand, Mode=OneWay}"
                                        CommandParameter="{Binding SelectedItems, ElementName=dg1}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <data:DataGrid.Columns>
                <data:DataGridTextColumn Binding="{Binding ID}"
                                         IsReadOnly="True"
                                         MaxWidth="40"
                                         Header="ID"
                                         Width="SizeToHeader" />
                <data:DataGridTemplateColumn Header="Foto">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Multimedia, Converter={StaticResource FirstImageConverter}}"
                                   Width="70"
                                   Height="100" />
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTextColumn Binding="{Binding FirstName}"
                                         Header="Nome" />
                <data:DataGridTextColumn Binding="{Binding LastName}"
                                         Header="Cognome" />
                <data:DataGridTextColumn Binding="{Binding EmailAddress}"
                                         Header="Email" />
                <data:DataGridTextColumn Binding="{Binding ResidenceCity}"
                                         Header="Città" />
                <data:DataGridCheckBoxColumn Binding="{Binding Availability}"
                                             Header="Disponibilità" />
                <data:DataGridTemplateColumn Header="Tipo"
                                            Width="SizeToCells">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock VerticalAlignment="Center"
                                       Text="{Binding Type}" />
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                    <data:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox ItemsSource="{Binding Elements, Source={StaticResource PeopleTypeCollection}}"
                                      SelectedItem="{Binding Type, Mode=TwoWay, Converter={StaticResource TypeListConverter}}"
                                      DisplayMemberPath="Name" />
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellEditingTemplate>
                </data:DataGridTemplateColumn>
                
            </data:DataGrid.Columns>
        </data:DataGrid>
        <Grid Background="#FF72B2E4"
              Grid.Row="2"
              Height="40">
            <Button Content="GO"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Margin="5,0,0,0">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard1}"
                                                    ControlStoryboardOption="Play" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>

            <Border Padding="10,0"
                    Margin="30,0,0,0">
                <Rectangle x:Name="rectangle"
                           Fill="#FFF4F4F5"
                           CacheMode="BitmapCache"
                           RenderTransformOrigin="0.5,0.5"
                           Width="20"
                           Height="20"
                           HorizontalAlignment="Left">
                    <Rectangle.RenderTransform>
                        <CompositeTransform />
                    </Rectangle.RenderTransform>
                </Rectangle>
            </Border>
        </Grid>
    </Grid>
</view:ViewPageBase>
